﻿using DataModels.Entities.HomeService;
using DataModels.Enums.Home;
using System.ComponentModel.DataAnnotations;
using Utils;
using static DataModels.Enums.GeneralEnum;

namespace DataModels.Dto.Home
{
    public class GetProductInfo : PageRequest
    {
        /// <summary>
        /// 分类ID
        /// </summary>
        public Guid? CategoryUUID { get; set; }

        /// <summary>
        /// 小分类ID
        /// </summary>
        public Guid? SubCategoryUUID { get; set; }

        /// <summary>
        /// 是否推荐
        /// </summary>
        public Status? IsRecommend { get; set; }

        /// <summary>
        /// 拼团
        /// </summary>
        public Status? IsGroup {  get; set; }

        /// <summary>
        /// 搜索
        /// </summary>
        public string? SearchWord { get; set; }
    }

    public class GetProductDto
    {
        public Guid UUID { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 商品图片
        /// </summary>
        public string ImageUrl { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        public string Supplier { get; set; }

        /// <summary>
        /// 是否推荐
        /// </summary>
        public Status IsRecommend { get; set; }

        /// <summary>
        /// 标签名称
        /// </summary>
        public List<string> Tags { get; set; }

        /// <summary>
        /// 价格
        /// </summary>
        public Decimal Price { get; set; }

        /// <summary>
        /// 是否拼团商品
        /// </summary>
        public Status IsGroup { get; set; }
    }

    public class GetProductDetailDto
    {
        public Guid UUID { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 成交数量
        /// </summary>
        public int DealtQuantity { get; set; }

        /// <summary>
        /// 副标题
        /// </summary>
        public string Subtitle { get; set; }

        /// <summary>
        /// 商品描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 是否推荐
        /// </summary>
        public Status IsRecommend { get; set; }

        /// <summary>
        /// 供应商
        /// </summary>
        public string Supplier { get; set; }

        /// <summary>
        /// 商品图片
        /// </summary>
        public List<string> ImageUrls { get; set; }


        /// <summary>
        /// 标签
        /// </summary>
        public List<ProductTagDto> Tags { get; set; }

        /// <summary>
        /// 是否拼团商品
        /// </summary>
        public Status IsGroup { get; set; }

        /// <summary>
        /// 拼团结束时间
        /// </summary>
        public DateTime? GroupEndTime { get; set; }

        /// <summary>
        /// 成团人数
        /// </summary>
        public int GroupCount { get; set; }

        /// <summary>
        /// 最大成团人数
        /// </summary>
        public int MaxGroupCount { get; set; }

        /// <summary>
        /// 规格
        /// </summary>
        public List<SpecificationTto> Specifications { get; set; }

        //public Dictionary<DateTime, List<TimeSlotConfig>> TimeSlot { get; set; }
    }

    public class SpecificationTto
    {

        public Guid SpecificationUUID { get; set; }

        /// <summary>
        /// 商品价格
        /// </summary>
        public decimal Price { get; set; }

        /// <summary>
        /// 商品拼团价格
        /// </summary>
        public decimal GroupPrice { get; set; }

        /// <summary>
        /// 原始价格 - 非购买价格
        /// </summary>
        public decimal OriginalPrice { get; set; }

        /// <summary>
        /// 商品规格名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 单位    一年 ，月，天，次等
        /// </summary>
        public string Unit { get; set; }

        /// <summary>
        /// 剩余数量
        /// </summary>
        public int Count { get; set; }
    }

    public class ProductTagDto
    {
        /// <summary>
        /// 标签名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 介绍
        /// </summary>
        public string Description { get; set; }
    }

    public class SubmitOrderInfo
    {
        /// <summary>
        /// 商品UUID
        /// </summary>
        [GeneralRequired]
        public Guid ProductUUID { get; set; }

        /// <summary>
        /// 规格UUID
        /// </summary>
        [GeneralRequired]
        public Guid SpecificationUUID { get; set; }

        /// <summary>
        /// 是否参团购买
        /// </summary>
        public Status JoinGroup { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        [GeneralRequired]
        public int Count { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        [GeneralRequired]
        public Guid AddressUUID { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 备注的图片
        /// </summary>
        public List<string>? ImageUrls { get; set; } = [];

        /// <summary>
        /// 预约时间规则UUID
        /// </summary>
        //[GeneralRequired]
        //public Guid ProductTimeRuleUUID { get; set; }

        /// <summary>
        /// 服务日期
        /// </summary>
        [GeneralRequired]
        public DateTime ServiceDate { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        [GeneralRequired]
        public string StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        [GeneralRequired]
        public string EndTime { get; set; }
    }

    public class OrderPaymentInfo
    {
        /// <summary>
        /// 订单UUID
        /// </summary>
        [GeneralRequired]
        public Guid OrderUUID { get; set; }

    }

    public class SubmitOrderComment
    {
        /// <summary>
        /// 订单UUID
        /// </summary>
        [GeneralRequired]
        public Guid OrderUUID { get; set; }

        public StarRating StarRating { get; set; } = StarRating.FiveStars;

        [GeneralRequired]
        public string Text { get; set; }

        public List<string>? Urls { get; set; }
    }


    public class GetOrderCommentInfo : PageRequest
    {
        [GeneralRequired]
        public Guid ProductUUID { get; set; }

        /// <summary>
        /// 筛选星级评分
        /// </summary>
        public List<StarRating> sr { get; set; } = [StarRating.FiveStars, StarRating.FourStars, StarRating.ThreeStars, StarRating.TwoStars, StarRating.OneStar];

        /// <summary>
        /// 筛选有图的
        /// </summary>
        public Status FilterImages { get; set; } = Status.Disable;

    }

    public class GetOrderCommentDto 
    {
        public Guid UUID { get; set; }

        public Guid UserUUID { get; set; }

        public string UserName { get; set; }

        public DateTime CreateTime { get; set; }

        public StarRating StarRating { get; set; }

        public string Content { get;set; }

        public List<string> ImageUrls { get; set; } = [];
    }

    public class CommentStatisticsResult
    {
        /// <summary>
        /// 评论总数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 有图片评论数量
        /// </summary>
        public int ImageCount { get; set; }

        /// <summary>
        /// 平均评分（保留两位小数）
        /// </summary>
        public decimal AverageRating { get; set; }

        /// <summary>
        /// 各星级评分的数量分布（键：星级，值：数量）
        /// </summary>
        public Dictionary<int, int> RatingDistribution { get; set; } = new Dictionary<int, int>
        {
            { 1, 0 },
            { 2, 0 },
            { 3, 0 },
            { 4, 0 },
            { 5, 0 }
        };
    }
    public class GetOrderInfo : PageRequest
    {
        public HomeServcieOrderStatus? OrderStatus { get; set; }
    }
}
